<?php
namespace Addons\TopMenu\Controller;

use Home\Controller\AddonsController;

class TopMenuController extends AddonsController
{

    function lists()
    {
        $model = $this->getModel();
        $page = I('p', 1, 'intval');
        $list_data = $this->_get_model_list($model, $page, 'sort asc, id asc');
        $this->assign($list_data);
        // dump($list_data);
        
        $this->display();
    }
    // 编辑模型
    public function edit($model = null, $id = 0)
    {
        if (IS_POST) {
            D('Common/TopMenu')->clear();
        }
        is_array($model) || $model = $this->getModel($model);
        $templateFile = $this->getAddonTemplate($model['template_edit']);
        parent::common_edit($model, $id, $templateFile);
    }
    
    // 增加模型
    public function add($model = null)
    {
        if (IS_POST) {
            D('Common/TopMenu')->clear();
        }
        is_array($model) || $model = $this->getModel($model);
        $templateFile = $this->getAddonTemplate($model['template_add']);
        
        parent::common_add($model, $templateFile);
    }
    
    // 删除模型
    public function del($model = null, $ids = null)
    {
        D('Common/TopMenu')->clear();
        parent::common_del($model, $ids);
    }
}
